package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     * 选择一个
     *
     * @param shoppingCartQuery 购物车查询
     * @return {@link ShoppingCart}
     */
    ShoppingCart selectOne(ShoppingCart shoppingCartQuery);

    /**
     * 插入
     *
     * @param shoppingCart 购物车
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 更新
     *
     * @param shoppingCart 购物车
     */
    void update(ShoppingCart shoppingCart);

    /**
     * 列表
     *
     * @param shoppingCartQuery 购物车查询
     * @return {@link List}<{@link ShoppingCart}>
     */
    List<ShoppingCart> list(ShoppingCart shoppingCartQuery);

    /**
     * 清洁
     *
     * @param currentId 当前id
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void clean(Long userId);
}
